import ChatApi from '@/api/ChatApi';
import { ChatEntity } from '@/entities/ChatEntity';

export default class ChatBusiness {
  /**
   * 添加一个聊天列表记录（会话记录）
   * @param senderId 发送者id（格式：T,1 或者 L,1）
   * @param receiverId 接收者id
   */
  static addChatSession(senderId: string, receiverId: string) {
    return ChatApi.addChatSession(senderId, receiverId);
  }


  /**
   * 删除会话
   * @param senderId
   * @param receiverId
   */
  static delChatSession(senderId: string, receiverId: string) {
    return ChatApi.delChatSession(senderId, receiverId);
  }

  /**
   * 获取会话列表
   * @param senderId
   */
  static getChatSession(senderId: string) {
    return ChatApi.getChatSession(senderId);
  }

  /**
   * 添加一个聊天信息
   * @param addChat 聊天信息
   */
  static addChatMessage(addChat: ChatEntity.IAddChatMessage) {
    return ChatApi.addChatMessage(addChat);
  }

  /**
   * 获取发送者和接收者之间的聊天记录
   * @param senderId
   * @param receiverId
   * @param page 第几页
   * @param limit 每页返回的个数
   */
  static getChatMessage(senderId: string, receiverId: string, page: number, limit: number) {
    return ChatApi.getChatMessage(senderId, receiverId, page, limit);
  }

  /**
   * 获取会话列表的最新一条消息
   * @param senderId
   */
  static getChatSessionLastOneMessageList(senderId: string) {
    return ChatApi.getChatSessionLastOneMessageList(senderId);
  }

  /**
   * 获取当前 sender 和 receiver 会话的最新消息
   * @param senderId
   * @param receiverId
   */
  static getCurrentChatSessionLastOneMessage(senderId: string, receiverId: string) {
    return ChatApi.getCurrentChatSessionLastOneMessage(senderId, receiverId);
  }

  /**
   * 离开会话
   * @param data
   */
  static leaveChatSession(data: { sessionId: number, senderId: string, receiverId: string }) {
    return ChatApi.leaveChatSession(data);
  }

  /**
   * 清除sender的获取消息的游标
   * @param senderId 
   */
  static clearSenderSessionCursor(senderId: string) {
    return ChatApi.clearSenderSessionCursor(senderId)
  }
}